package com.woniuxy.controller;


import com.woniuxy.controller.form.AccountRuleForm;
import com.woniuxy.controller.info.AccountRuleInfo;
import com.woniuxy.exception.DdException;
import com.woniuxy.service.AccountRoleService;
import com.woniuxy.utils.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author hujianying
 * @since 2022-03-29
 */
@RestController
@RequestMapping("/accountRole")
@Api(tags = "账号角色关联相关接口")
public class AccountRoleController {


    @Resource
    private AccountRoleService accountRuleService;

    //根据账号id查询角色id
    @ApiOperation("根据账号id查询角色id")
    @GetMapping("/findRuleId")
    public Result findRuleIdByAccountId(Integer id){
        AccountRuleInfo ruleIdByAccountId = accountRuleService.findRuleIdByAccountId(id);
        return Result.success(200,"请求成功",ruleIdByAccountId);
    }

    //修改中间表，根据accountid新增
    @ApiOperation("修改中间表，根据accountid新增")
    @PostMapping("/updateAccountRule")
    public Result updateAccountRule(@RequestBody AccountRuleForm arf) throws DdException {
        accountRuleService.updateAccountRule(arf);
        return Result.success(200,"修改成功",null);
    }
}

